const { defineConfig } = require("@vue/cli-service");
// const VueLoaderPlugin = require("vue-loader/lib/plugin");
const { ModuleFederationPlugin } = require("webpack").container;

module.exports = defineConfig({
  publicPath: "auto",
  transpileDependencies: true,
  devServer: {
    port: 8080,
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  },
  configureWebpack: {
    optimization: {
      splitChunks: false, // 禁用代码分割
    },
    plugins: [
      new ModuleFederationPlugin({
        // 唯一ID，用于标记当前服务
        name: "federation",
        // 提供给其他服务加载的文件
        filename: "remoteEntry.js",
        library: { type: "window", name: "federation" },
        // 需要暴露的模块，使用时通过 `${name}/${expose}` 引入
        exposes: {
          "./TestComponent.vue": "./src/components/TestComponent.vue",
          "./TestUtil.ts": "./src/components/TestUtil.ts",
        },
        // shared: {
        //   // 共享库配置，确保版本一致，避免冲突
        //   vue: {
        //     singleton: true,
        //     eager: true,
        //     requiredVersion: require("./package.json").dependencies.vue,
        //   },
        // },
      }),
    ],
  },
});
